import request from '@/utils/request'
import { makeFormData } from '@/utils/util'

const auditApi = {
  config: 'web/course_audit/get_auditor_setting',
  submit: 'web/course_audit/add_auditor'
}

export function getAuditConfig (data = {}) {
  return request({
    url: auditApi.config,
    method: 'post',
    data: makeFormData(data)
  })
}

export function auditSubmit (params = {}, data = {}) {
  return request({
    url: auditApi.submit,
    method: 'post',
    params,
    data: makeFormData(data)
  })
}

const scheduleApi = {
  nurseryClasses: 'web/nursery_schedule/classes_list',
  nurserySchule: 'web/nursery_schedule/teacher_detail',
  nurserySchuleAdd: 'web/nursery_schedule/add',
  nurserySchuleUpdate: 'web/nursery_schedule/update',
  nurseryCheck: 'web/nursery_schedule/get_schedule_check',
  courseTypeByName: 'web/course/type_name_by_course_type',
  getTemps: 'web/nursery_schedule/load_temp',
  saveTemps: 'web/nursery_schedule/temp_save',
  delTemps: 'web/nursery_schedule/delete_temp',
  autoSchedule: 'web/nursery_schedule/addNurseryInstrationByDay',
  checkSchedule: 'web/nursery_schedule/submit_check',
  earlySchule: 'web/course_early/plan_by_date',
  earlyClasses: 'web/course_early/early_classes_list',
  earlySchuleAdd: 'web/course_early/create_plan',
  earlyScheduleDel: 'web/course_early/deleted',
  earlyChildren: 'web/course_early/children_list',
  earlySchedulePlan: 'web/course_early/plan_children',

  nurseryExportExcel: 'web/nursery_schedule/export_excel',

  door2DoorChildren: 'web/nursery_schedule/door2DoorChildren',
  schedulerDetail: 'web/nursery_schedule/scheduler_detail'
}

export function getNurseryClasses (params = {}) {
  return request({
    url: scheduleApi.nurseryClasses,
    method: 'post',
    params
  })
}

export function getNurseryCheck (data = {}) {
  return request({
    url: scheduleApi.nurseryCheck,
    method: 'post',
    data: makeFormData(data)
  })
}

export function getNurserySchule (data = {}) {
  return request({
    url: scheduleApi.nurserySchule,
    method: 'post',
    data: makeFormData(data)
  })
}

export function nurserySchuleSubmit (data = {}, type) {
  return request({
    url: scheduleApi[type === 'add' ? 'nurserySchuleAdd' : 'nurserySchuleUpdate'],
    method: 'post',
    data: makeFormData(data)
  })
}

export function getCourseTypeByName (params, data = {}) {
  return request({
    url: scheduleApi.courseTypeByName,
    method: 'post',
    params,
    data: makeFormData(data)
  })
}

export function getTemps (params) {
  return request({
    url: scheduleApi.getTemps,
    method: 'post',
    params
  })
}

export function saveTemps (params, data = {}) {
  return request({
    url: scheduleApi.saveTemps,
    method: 'post',
    params,
    data: makeFormData(data)
  })
}

export function delTemps (params, data = {}) {
  return request({
    url: scheduleApi.delTemps,
    method: 'post',
    params,
    data: makeFormData(data)
  })
}

export function autoSchedule (params = {}) {
  return request({
    url: scheduleApi.autoSchedule,
    method: 'post',
    params
  })
}

export function checkSchedule (params = {}, data = {}) {
  return request({
    url: scheduleApi.checkSchedule,
    method: 'post',
    params,
    data: makeFormData(data)
  })
}

export function getEarlyClasses (params) {
  return request({
    url: scheduleApi.earlyClasses,
    method: 'post',
    params
  })
}

export function getEarlySchule (data = {}) {
  return request({
    url: scheduleApi.earlySchule,
    method: 'post',
    data: makeFormData(data)
  })
}

export function earlySchuleAdd (params, data = {}) {
  return request({
    url: scheduleApi.earlySchuleAdd,
    method: 'post',
    params,
    data: makeFormData(data)
  })
}

export function earlyScheduleDel (data = {}) {
  return request({
    url: scheduleApi.earlyScheduleDel,
    method: 'post',
    data: makeFormData(data)
  })
}

export function getEarlyChildren (data = {}) {
  return request({
    url: scheduleApi.earlyChildren,
    method: 'post',
    data: makeFormData(data)
  })
}

export function earlySchedulePlan (data = {}) {
  return request({
    url: scheduleApi.earlySchedulePlan,
    method: 'post',
    data: makeFormData(data)
  })
}

export function nurseryExportExcel (params = {}) {
  return request({
    url: scheduleApi.nurseryExportExcel,
    method: 'post',
    params
  })
}

export function getDoor2DoorChildren (params = {}) {
  return request({
    url: scheduleApi.door2DoorChildren,
    method: 'post',
    params
  })
}

export function getSchedulerDetail (data = {}) {
  return request({
    url: scheduleApi.schedulerDetail,
    method: 'post',
    data: makeFormData(data)
  })
}
